using Microsoft.AspNetCore.Mvc;
using star_questionnair.Models;
using star_questionnair.Services;

namespace star_questionnair.Controllers;

[Route("differenceLevelQuestionAnalysis")]
[ApiController]
public class DifferenceLevelQuestionAnalysisController : ControllerBase
{
    private readonly IDifferenceLevelQuestionAnalysisService _differenceLevelQuestionAnalysisService;

        public DifferenceLevelQuestionAnalysisController(IDifferenceLevelQuestionAnalysisService differenceLevelQuestionAnalysisService)
        {
            _differenceLevelQuestionAnalysisService = differenceLevelQuestionAnalysisService;
        }

        // 性别差异分析
        [HttpGet("gender1/{questionId}")]
        public async Task<ActionResult<Dictionary<bool, double>>> GetGenderDifference(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetGenderDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 年龄差异分析
        [HttpGet("age1/{questionId}")]
        public async Task<ActionResult<Dictionary<string, double>>> GetAgeDifference(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetAgeDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 公司差异分析
        [HttpGet("enterprise1/{questionId}")]
        public async Task<ActionResult<Dictionary<string, double>>> GetEnterpriseDifference(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetEnterpriseDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 职位差异分析
        [HttpGet("role1/{questionId}")]
        public async Task<ActionResult<Dictionary<string, double>>> GetRoleDifference(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetRoleDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 性别层次比例分析
        [HttpGet("gender2/{questionId}")]
        public async Task<ActionResult<Dictionary<bool, Dictionary<int, double>>>> GetGenderLevelProportions(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetGenderLevelProportionsAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 公司层次比例分析
        [HttpGet("enterprise2/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<int, double>>>> GetEnterpriseLevelProportions(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetEnterpriseLevelProportionsAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 职位层次比例分析
        [HttpGet("role2/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<int, double>>>> GetRoleLevelProportions(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetRoleLevelProportionsAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 年龄层次比例分析
        [HttpGet("age2/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<int, double>>>> GetAgeLevelProportions(int questionId)
        {
            var result = await _differenceLevelQuestionAnalysisService.GetAgeLevelProportionsAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }
}